home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / qwin / drag.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-09-10  |  4.5 KB  |  149 lines

  1. VERSION 2.00
  2. Begin Form frmDrag 
  3.    Caption         =   "Drag & Use"
  4.    ClientHeight    =   3015
  5.    ClientLeft      =   1890
  6.    ClientTop       =   3255
  7.    ClientWidth     =   6435
  8.    Height          =   3705
  9.    Left            =   1830
  10.    LinkTopic       =   "Form2"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3015
  14.    ScaleWidth      =   6435
  15.    Top             =   2625
  16.    Width           =   6555
  17.    Begin CommandButton Command1 
  18.       Caption         =   "Exit"
  19.       Height          =   375
  20.       Left            =   5760
  21.       TabIndex        =   3
  22.       Top             =   2640
  23.       Width           =   735
  24.    End
  25.    Begin DriveListBox Drive1 
  26.       DragIcon        =   DRAG.FRX:0000
  27.       Height          =   315
  28.       Left            =   240
  29.       TabIndex        =   2
  30.       Top             =   120
  31.       Width           =   1935
  32.    End
  33.    Begin FileListBox File1 
  34.       FontBold        =   -1  'True
  35.       FontItalic      =   0   'False
  36.       FontName        =   "System"
  37.       FontSize        =   9.75
  38.       FontStrikethru  =   0   'False
  39.       FontUnderline   =   0   'False
  40.       Height          =   1950
  41.       Left            =   2400
  42.       Pattern         =   "*.txt;*.bmp;*.exe;*.hlp"
  43.       TabIndex        =   1
  44.       Top             =   120
  45.       Width           =   2055
  46.    End
  47.    Begin DirListBox Dir1 
  48.       DragIcon        =   DRAG.FRX:0302
  49.       FontBold        =   -1  'True
  50.       FontItalic      =   0   'False
  51.       FontName        =   "System"
  52.       FontSize        =   9.75
  53.       FontStrikethru  =   0   'False
  54.       FontUnderline   =   0   'False
  55.       Height          =   1380
  56.       Left            =   240
  57.       TabIndex        =   0
  58.       Top             =   600
  59.       Width           =   1935
  60.    End
  61.    Begin Image Image2 
  62.       Height          =   495
  63.       Left            =   2040
  64.       Picture         =   DRAG.FRX:0604
  65.       Top             =   2160
  66.       Width           =   2550
  67.    End
  68.    Begin Image Image1 
  69.       BorderStyle     =   1  'Fixed Single
  70.       Height          =   1935
  71.       Left            =   4680
  72.       Stretch         =   -1  'True
  73.       Top             =   120
  74.       Width           =   1725
  75.    End
  76.    Begin Menu mnufile 
  77.       Caption         =   "&File"
  78.       Begin Menu mnuback 
  79.          Caption         =   "Back to EasyWin"
  80.       End
  81.    End
  82. Sub Command1_Click ()
  83. End Sub
  84. Sub Dir1_Change ()
  85.     file1.Path = Dir1.Path
  86. End Sub
  87. Sub Drive1_Change ()
  88.     Dir1.Path = Drive1.Drive
  89. End Sub
  90. Sub File1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  91.     file1.DragIcon = Drive1.DragIcon
  92.     file1.Drag
  93. End Sub
  94. Sub Form_Load ()
  95.     frmdrag.Width = 6525
  96.     frmdrag.Height = 3500
  97. End Sub
  98. Sub Image1_DragDrop (Source As Control, X As Single, Y As Single)
  99.     ' Get last three letters of the dragged filename
  100.     temp = Right$(file1.FileName, 3)
  101.     ' If dragged file is in the root, append filename.
  102.     If Mid(file1.Path, Len(file1.Path)) = "\" Then
  103.       dropfile = file1.Path & file1.FileName
  104.     ' If dragged file is not in root, append "\" and filename.
  105.     Else
  106.       dropfile = file1.Path & "\" & file1.FileName
  107.     End If
  108.       
  109.     image1.Picture = LoadPicture("")
  110.     Select Case temp
  111.     Case "txt"
  112.         X = Shell("Notepad " + dropfile, 1)
  113.     Case "bmp", "wmf", "rle", "ico"
  114.         image1.Picture = LoadPicture(dropfile)
  115.     Case "exe"
  116.         X = Shell(dropfile, 1)
  117.     Case "hlp"
  118.         X = Shell("WinHelp " + dropfile, 1)
  119.     Case "wri"
  120.         X = Shell("write " + dropfile, 1)
  121. 'add your own case example
  122.     'case "mak"
  123.     '   x = shell("c:\vb\vb.exe + dropfile, 1)
  124.     Case Else
  125.         nl = Chr$(10) + Chr$(13)
  126.         msg = "Try one of these file types:"
  127.         msg = nl + msg + nl + nl + "     .txt, .bmp, .exe, .hlp"
  128.         MsgBox msg
  129.     End Select
  130. End Sub
  131. Sub Image1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  132.     Select Case State
  133.     Case 0
  134.         ' Display a new icon when the source
  135.         ' enters the drop area.
  136.         file1.DragIcon = Dir1.DragIcon
  137.     Case 1
  138.         ' Display the original DragIcon when the source
  139.         ' leaves the drop area.
  140.         file1.DragIcon = Drive1.DragIcon
  141.     End Select
  142. ' Note that Dir1.DragIcon and Drive1.DragIcon have been
  143. ' set at design time. This allows you to load the "Enter
  144. ' and "Leave" icons for File1 at runtime without requiring
  145. ' that the user has those icons are on disc.
  146. End Sub
  147. Sub mnuback_Click ()
  148. End Sub
  149.